﻿using STT.Layer.Connection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using STT.Business;
namespace STT.Profile.UserControls
{
    public partial class UcBangDiem : System.Web.UI.UserControl
    {
        ToolBox tb = new ToolBox();
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadListDiem();
        }
        private void LoadListDiem()
        {
            GvDiemHV.DataSource = tb.GetDataTableById2("Get_DiemHocVien_Diem_byMahv", Session["Mahv"].ToString());
            GvDiemHV.DataBind();
        }

        protected void GvDiemHV_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GvDiemHV.PageIndex = e.NewPageIndex;
            LoadListDiem();
        }

        protected void btntemh_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton lbt = sender as LinkButton;
                foreach (GridViewRow row in GvDiemHV.Rows)
                {
                    Label lblMamh = row.FindControl("lblmamh") as Label;
                    LinkButton lbtmh = row.FindControl("btntemh") as LinkButton;
                    Control ctrl = row.FindControl("btntemh") as LinkButton;
                    Label lblmalop = ((Label)row.FindControl("lblmalop"));
                    Label lbltenlop = ((Label)row.FindControl("lbltenlop"));
                    if (ctrl != null)
                    {
                        LinkButton lbt1 = (LinkButton)ctrl;
                        if (lbt.ClientID == lbt1.ClientID)
                        {
                            pn_BDCaLop.Visible = true;
                            pn_BDCaNhan.Visible = false;
                            DataTable dt = BTbTKB.TbTKB_SelectByMaMHMaLop(lblmalop.Text, lblMamh.Text);
                            lblmonhoc2.Text = lbtmh.Text;
                            lbltenlop2.Text = dt.Rows[0]["TenLop"].ToString();
                            gvDSDiemHV.DataSource = dt;
                            gvDSDiemHV.DataBind();
                        }
                    }
                }
            }
            catch { }
        }

        protected void gvDSDiemHV_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
    
            
        }

        protected void gvDSDiemHV_RowDataBound(object sender, GridViewRowEventArgs e)
        {

        }

        protected void lbtBDCN_Click(object sender, EventArgs e)
        {
            pn_BDCaLop.Visible = false;
            pn_BDCaNhan.Visible = true;
        }
    }
}